<html xmlns="http://www.w3.org/1999/xhtml"  
      xmlns:h="http://java.sun.com/jsf/html"  
      xmlns:f="http://java.sun.com/jsf/core"  
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets"> 

    <ui:composition template="../index.xhtml">
        <ui:define name="conteudo">
            <h:form>
                <h:panelGrid columns="2">
                    <h:outputText value="Selecione o caixa: "/>
                    <p:selectOneMenu value="#{configuraControler.caixa.id}">  
                        <f:selectItem itemValue="0" itemLabel="Selecione"/>
                        <f:selectItems value="#{caixaControler.listCaixas}" var="caixa" itemValue="#{caixa.id}" itemLabel="#{caixa.nome} ----- #{caixa.ip}"/> 
                        <p:ajax event="change" update=":formDados" listener="#{configuraControler.retornaConfiguracao()}" onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>
                    </p:selectOneMenu>
                </h:panelGrid>
                <p:separator />
            </h:form>

            <p:panel header="Configurações do sistema">
                <h:form id="formDados">
                    <p:messages/>
                    <h:inputHidden value="#{configuraControler.configuracao.id}"/>
                    <h:panelGrid columns="4">

                        <h:panelGrid columns="1" >
                            <h:outputText value="Mensagem do cupom: "/>
                            <p:inputText maxlength="30" value="#{configuraControler.configuracao.mensagemCupom}"  disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}"/>
                        </h:panelGrid>

                        <h:panelGrid columns="1">
                            <h:outputText value="Titulo tela caixa: "/>
                            <p:inputText value="#{configuraControler.configuracao.tituloTelaCaixa}" disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}"/>
                        </h:panelGrid>

                        <h:panelGrid columns="1">
                            <h:outputText value="Porta Impressora: "/>
                            <p:selectOneMenu style="width: 150px;" value="#{configuraControler.configuracao.portaEcf}" disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}">  
                                <f:selectItem itemValue="COM1" itemLabel="COM1"/> 
                                <f:selectItem itemValue="COM2" itemLabel="COM2"/> 
                                <f:selectItem itemValue="COM3" itemLabel="COM3"/> 
                                <f:selectItem itemValue="COM4" itemLabel="COM4"/> 
                                <f:selectItem itemValue="COM5" itemLabel="COM5"/> 
                                <f:selectItem itemValue="COM6" itemLabel="COM6"/> 
                                <f:selectItem itemValue="COM7" itemLabel="COM7"/> 
                                <f:selectItem itemValue="COM8" itemLabel="COM8"/> 
                                <f:selectItem itemValue="COM9" itemLabel="COM9"/> 
                                <f:selectItem itemValue="COM10" itemLabel="COM10"/> 
                                <f:selectItem itemValue="COM11" itemLabel="COM11"/> 
                                <f:selectItem itemValue="COM12" itemLabel="COM12"/> 
                                <f:selectItem itemValue="COM13" itemLabel="COM13"/> 
                                <f:selectItem itemValue="COM14" itemLabel="COM14"/> 
                                <f:selectItem itemValue="COM15" itemLabel="COM15"/> 
                            </p:selectOneMenu>
                        </h:panelGrid>

                        <h:panelGrid columns="1">
                            <h:outputText value="Porta PinPed: "/>
                            <p:selectOneMenu style="width: 150px;" value="#{configuraControler.configuracao.portaPinpad}" disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}">  
                                <f:selectItem itemValue="COM1" itemLabel="COM1"/> 
                                <f:selectItem itemValue="COM2" itemLabel="COM2"/> 
                                <f:selectItem itemValue="COM3" itemLabel="COM3"/> 
                                <f:selectItem itemValue="COM4" itemLabel="COM4"/> 
                                <f:selectItem itemValue="COM5" itemLabel="COM5"/> 
                                <f:selectItem itemValue="COM6" itemLabel="COM6"/> 
                                <f:selectItem itemValue="COM7" itemLabel="COM7"/> 
                                <f:selectItem itemValue="COM8" itemLabel="COM8"/> 
                                <f:selectItem itemValue="COM9" itemLabel="COM9"/> 
                                <f:selectItem itemValue="COM10" itemLabel="COM10"/> 
                                <f:selectItem itemValue="COM11" itemLabel="COM11"/> 
                                <f:selectItem itemValue="COM12" itemLabel="COM12"/> 
                                <f:selectItem itemValue="COM13" itemLabel="COM13"/> 
                                <f:selectItem itemValue="COM14" itemLabel="COM14"/> 
                                <f:selectItem itemValue="COM15" itemLabel="COM15"/> 
                            </p:selectOneMenu>
                        </h:panelGrid>

                        <h:panelGrid columns="1">
                            <h:outputText value="IP Servidor: "/>
                            <p:inputText value="#{configuraControler.configuracao.ipServidor}" disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}">
                                <p:commandButton image="ui-icon-transfer-e-w" title="Verificar conexão com o servidor" onclick="statusDialog.show();" onsuccess="statusDialog.hide();"
                                                 actionListener="#{caixaControler.verificaConexao(configuraControler.configuracao.ipServidor)}" update="@form" disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}"/>
                            </p:inputText>
                        </h:panelGrid>

                        <h:panelGrid columns="1">
                            <h:outputText value="Cor janelas internas: " title="Cor padrão: 236,233,216"/>
                            <p:inputText id="corJanelas" value="#{configuraControler.configuracao.corJanelasInternas}" disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}">
                                <p:commandButton image="ui-icon-arrowrefresh-1-w" title="Usar cor padrão." onclick="statusDialog.show();" onsuccess="statusDialog.hide();"
                                                 actionListener="#{configuraControler.setorConfPadrao()}" update="corJanelas" disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}"/>
                            </p:inputText>
                        </h:panelGrid>

                        <h:panelGrid columns="1">
                            <h:outputText value="Senha p/ cancelamento de item: "/>
                            <p:selectOneMenu style="width: 150px;" value="#{configuraControler.configuracao.senhaCancelaItem}" disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}">  
                                <f:selectItem itemValue="S" itemLabel="SIM"/> 
                                <f:selectItem itemValue="N" itemLabel="NÃO"/> 
                            </p:selectOneMenu>
                        </h:panelGrid>

                        <h:panelGrid columns="1">
                            <h:outputText value="Senha p/ cancelamento de cupom: "/>
                            <p:selectOneMenu style="width: 150px;" value="#{configuraControler.configuracao.senhaCancelaCupom}" disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}">  
                                <f:selectItem itemValue="S" itemLabel="SIM"/> 
                                <f:selectItem itemValue="N" itemLabel="NÃO"/> 
                            </p:selectOneMenu>
                        </h:panelGrid>

                        <h:panelGrid columns="1">
                            <h:outputText value="Imprimir abertura/fechamento de caixa: "/>
                            <p:selectOneMenu style="width: 150px;" value="#{configuraControler.configuracao.imprimeAberturaFechamentoCaixa}" disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}">  
                                <f:selectItem itemValue="S" itemLabel="SIM"/> 
                                <f:selectItem itemValue="N" itemLabel="NÃO"/> 
                            </p:selectOneMenu>
                        </h:panelGrid>

                        <h:panelGrid columns="1">
                            <h:outputText value="Controle de caixa: "/>
                            <p:selectOneMenu style="width: 150px;" value="#{configuraControler.configuracao.controle_de_caixa}" disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}">  
                                <f:selectItem itemValue="S" itemLabel="SIM"/> 
                                <f:selectItem itemValue="N" itemLabel="NÃO"/> 
                            </p:selectOneMenu>
                        </h:panelGrid>

                        <h:panelGrid columns="1">
                            <h:outputText value="Gerar NF-e no caixa? "/>
                            <p:selectOneMenu style="width: 150px;" value="#{configuraControler.configuracao.imprime_nfe_caixa}" disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}">  
                                <f:selectItem itemValue="S" itemLabel="SIM"/> 
                                <f:selectItem itemValue="N" itemLabel="NÃO"/> 
                            </p:selectOneMenu>
                        </h:panelGrid>

                        <h:panelGrid columns="1">
                            <h:outputText value="Caminho imagens produtos: "/>
                            <p:inputText value="#{configuraControler.configuracao.caminhoImagensProdutos}"  disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}"/>
                        </h:panelGrid>

                        <h:panelGrid columns="1">
                            <h:outputText value="Caminho imagens layout: "/>
                            <p:inputText value="#{configuraControler.configuracao.caminhoImagensLayout}"  disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}"/>
                        </h:panelGrid>

                        <h:panelGrid columns="1">
                            <h:outputText value="Market Ativo? "/>
                            <p:selectOneMenu style="width: 150px;" value="#{configuraControler.configuracao.marketingAtivo}" disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}">  
                                <f:selectItem itemValue="S" itemLabel="SIM"/> 
                                <f:selectItem itemValue="N" itemLabel="NÃO"/>
                                <p:ajax event="change" update="market" />
                            </p:selectOneMenu>
                        </h:panelGrid>

                        <h:panelGrid columns="1">
                            <h:outputText value="Caminho imagens market: "/>
                            <p:inputText id="market" value="#{configuraControler.configuracao.caminhoImagensMarketing}" disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0') || configuraControler.configuracao.marketingAtivo.toString().equalsIgnoreCase('N')}"/>
                        </h:panelGrid>

                        <h:panelGrid columns="1">
                            <h:outputText value="Resolução da tela: "/>
                            <p:selectOneMenu style="width: 150px;" value="#{configuraControler.configuracao.idEcfResolucao.id}" disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}">  
                                <f:selectItems value="#{resolucaoControler.retornaResolucao()}" var="resol" itemValue="#{resol.id}" itemLabel="#{resol.resolucaoTela}"/> 
                            </p:selectOneMenu> 
                        </h:panelGrid>

                    </h:panelGrid>
                    <h:panelGrid columns="3">
                        <h:outputText value="Impressora:"/>
                        <p:selectOneMenu style="width: 300px;" value="#{configuraControler.configuracao.idEcfImpressora.id}" disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}" >  
                            <f:selectItems value="#{impressoraControler.retornaImpressoras()}" var="impr" itemValue="#{impr.id}" itemLabel="#{impr.marca} - #{impr.modelo} - #{impr.serie}"/> 
                        </p:selectOneMenu>
                        <p:commandButton action="#{impressoraControler.NovaImpressora('Impressora')}" value="+" ajax="false"/>

                        <h:outputText value="Empresa:"/>
                        <p:selectOneMenu style="width: 300px;" value="#{configuraControler.configuracao.idEcfEmpresa.id}" disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}" >  
                            <f:selectItems value="#{empresaControler.retornaEmpresas()}" var="empr" itemValue="#{empr.id}" itemLabel="#{empr.razaoSocial}"/> 
                        </p:selectOneMenu>
                        <p:commandButton action="#{impressoraControler.NovaImpressora('Empresa')}" value="+" ajax="false"/>
                    </h:panelGrid>
                    <p:defaultCommand target="btSalvar" /> 
                    <p:commandButton id="btSalvar"  disabled="#{configuraControler.caixa.id.toString().equalsIgnoreCase('0')}" action="#{configuraControler.salvar()}" value="Salvar" update="@form" onstart="statusDialog.show();" onsuccess="statusDialog.hide();"/>
                </h:form>
            </p:panel>
        </ui:define>
    </ui:composition>
</html>